var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_BoxIitemInfo_UIBindings = require("AA_UI_BoxIitemInfo_UIBindings");
var UIView = require("AA_UIView");
var Excel = require("AA_Excel");
var PlayerDataManager = require("AA_PlayerDataManager");
var BundleConfig = require("AA_BundleConfig");
var CommonUtils = require("AA_CommonUtils");
var Const_Hall = require("AA_Const_Hall");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_BoxIitemInfo = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    t.spriteMaterial = [];
    return t;
  }
  __extends(_creator, e);
  _creator.prototype._show = function (e) {
    this.auto_ui.node_cardFather.children.forEach(function (t, o) {
      t.active = o + 1 == e;
    });
    var t = [];
    Excel.Excel.shuiguo_all.forEach(function (o) {
      o.quality == e && -1 != o.isShow && t.push({
        id: o.id,
        isUnLock: PlayerDataManager.PlayerDataMgr.GetEquipDataById(o.id).isUnLock
      });
    });
    t.sort(function (e, t) {
      if (e.isUnLock) {
        if (t.isUnLock) {
          return e.id - t.id;
        } else {
          return -1;
        }
      } else {
        return 1;
      }
    });
    var o = t.filter(function (e) {
      return e.isUnLock;
    });
    if (0 == o.length) {
      this.auto_ui.txt_jiLvLabel.string = "每个水果碎片的概率:0%";
    } else {
      this.auto_ui.txt_jiLvLabel.string = "每个水果碎片的概率:" + (100 / o.length).toFixed(2) + "%";
    }
    this.auto_ui.node_itemFather.children.forEach(function (e) {
      return e.active = false;
    });
    for (var n = 0; n < t.length; n++) {
      t[n];
      var i = undefined;
      if (n > this.auto_ui.node_itemFather.childrenCount) {
        i = this.auto_ui.node_itemFather.children[n];
      } else {
        (i = cc.instantiate(this.auto_ui.node_ItemIcon)).parent = this.auto_ui.node_itemFather;
      }
      i.active = true;
      this.ShowItem(i, t[n]);
    }
  };
  _creator.prototype._clickListener = function () {
    this._close();
  };
  _creator.prototype.ShowItem = function (e, t) {
    return __awaiter(this, undefined, undefined, function () {
      var o;
      var n = this;
      return __generator(this, function () {
        this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/player/player" + (t.id - 1e3) + "_1", cc.SpriteFrame).then(function (o) {
          var i = e.getChildByName("icon").getComponent(cc.Sprite);
          i.spriteFrame = o;
          CommonUtils.default.LimitSpriteMaxSize(i, Const_Hall.equipIconSize);
          i.setMaterial(0, t.isUnLock ? n.spriteMaterial[0] : n.spriteMaterial[1]);
        });
        o = Excel.Excel.shuiguo(t.id).quality;
        t.isUnLock || (o = 0);
        this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/quality/quality_" + o, cc.SpriteFrame).then(function (t) {
          e.getChildByName("quality").getComponent(cc.Sprite).spriteFrame = t;
        });
        e.getChildByName("lock").active = !t.isUnLock;
        return [2];
      });
    });
  };
  __decorate([_property(UI_BoxIitemInfo_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  __decorate([_property([cc.Material])], _creator.prototype, "spriteMaterial", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_BoxIitemInfo;